<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <link rel="stylesheet" type="text/css" href="static/css/default.css" media="all" />
        <link rel="stylesheet" type="text/css" href="static/css/layout.css" media="all" />
        <link rel="stylesheet" type="text/css" href="static/css/general.css"/>
        <link rel="stylesheet" type="text/css" href="static/css/jquery.theme.css" media="all" />
        <link rel="stylesheet" type="text/css" href="static/css/jquery.core.css" media="all" />
        <link rel="stylesheet" type="text/css" href="static/css/jquery.ui.datepicker.css" media="all" />

        <link rel="stylesheet" type="text/css" href="static/css/jquery.ui.button.css" media="all" />
        <link rel="stylesheet" type="text/css" href="static/css/jquery.ui.resizable.css" media="all" />
        <link rel="stylesheet" type="text/css" href="static/css/jquery.ui.dialog.css" media="all" />
        <link rel="stylesheet" type="text/css" href="static/css/jquery.ui.tooltip.css" media="all" />
        <link rel="stylesheet" type="text/css" href="static/css/jquery.ui.tooltip.css" media="all" />
        <link rel="stylesheet" type="text/css" href="static/css/jquery.ui.menu.css" media="all" />
        <link rel="stylesheet" type="text/css" href="static/css/jquery.ui.override.css" media="all" />
        <link rel="stylesheet" type="text/css" href="static/css/list_favorite.css" media="all" />

        <link rel="stylesheet" type="text/css" href="static/css/user-own.css" media="all" />
        <link rel="stylesheet" type="text/css" href="static/css/profile.css" media="all" />
        <script type='text/javascript' src='static/js/jquery.min.js'></script>
        <script type='text/javascript' src='static/js/menu.js'></script>
        <script type='text/javascript' src='static/js/jquery.ui.core.js'></script>
        <script type='text/javascript' src='static/js/jquery.ui.widget.js'></script>
        <script type='text/javascript' src='static/js/jquery.ui.datepicker.js'></script>

        <script type='text/javascript' src='static/js/jquery.ui.button.js'></script>
        <script type='text/javascript' src='static/js/jquery.ui.draggable.js'></script>
        <script type='text/javascript' src='static/js/jquery.ui.mouse.js'></script>
        <script type='text/javascript' src='static/js/jquery.ui.position.js'></script>
        <script type='text/javascript' src='static/js/jquery.ui.resizable.js'></script>
        <script type='text/javascript' src='static/js/jquery.ui.dialog.js'></script>
        <script type='text/javascript' src='static/js/jquery.ui.tooltip.js'></script>
        <script type='text/javascript' src='static/js/jquery.ui.menu.js'></script>

        <script type='text/javascript' src='static/js/general.js'></script>
        <script type='text/javascript' src='static/js/profile.js'></script>
        <script type="text/javascript" src="static/js/jqueryValidation.js"></script>
		<script type="text/javascript" src="static/js/renderdate.js"></script>
		<script>
			$(document).ready(function(){
		        $day.init();
		        //$validation.init();
		       // $("#profile_form").validate();
	            $('#profile_form').submit(function(){
	                //$('label.error').prepend('<br />');
	                $('label.error').prepend('&nbsp;');
	            });
			});
		</script>
    </head>
    <body>
        <div class="body">
            <div class="header">
                <div class="float-left text-left login">
                    <span>Welcome lampart.com.</span>
                    <a id="signin" class="sign-in" href="index.php?c=logout">Sign out</a>
                </div>

            </div>
            <div class="search">
                <div class="social-connect"></div>
                <div class="logo">
                    <a href="#" title="">Lampart.com</a>
                </div>
                <div class="search-control">
                    <form action="index.php?c=search" method="get" id="search_control">
                        <div class="search-category">
                            <div id="search_title" class="search-title">
                                <span id="search_category_title" style="font-size: 10px;">All  </span>
                                <img src="images/arrow_down.png" />
                            </div>
                            <ul id="search_menu" class="search-menu">
                                <li id="0" class="menu-option">All</li>
                                <li id="1" class="menu-option">Male</li>
                                <li id="2" class="menu-option">Female</li>
                            </ul>
                        </div>
                        <input type="hidden" id="search_controller" value="search" name="c" />
                        <input type="hidden" id="search_sex" value="" name="search[sex]" />
                        <input type="text" name="search[name]" size="15" />
                        <input type="submit" id="search" name="search[search]" value="Search" />
                    </form>
                </div>
            </div>
            <div class="content">
                <div class="left">
                    <div class='header'>My profile</div>
                    <div class="main">
                        <div class="image">
                            <img  width='150px' height='150px' src="<?php echo!empty($this->profile->picture) ? 'img/' . $this->profile->picture : 'img/0.gif'; ?>"/>
                        </div>
                        <table>
                            <tr><td class="profile_head">Username:</td><td class="profile_detail"><?php echo $this->profile->username; ?></td></tr>
                            <tr><td class="profile_head">Name:</td><td class="profile_detail"><?php echo $this->profile->name; ?></td></tr>
                            <tr><td class="profile_head">Sex:</td><td class="profile_detail"><?php echo $this->profile->sex == 1 ? 'Male' : 'Female';; ?></td></tr>
                            <tr><td class="profile_head">Address:</td><td class="profile_detail"><?php echo $this->profile->address; ?></td></tr>
                            <tr><td class="profile_head">Birthday:</td><td class="profile_detail"><?php echo date('d-m-Y', $this->profile->birthday); ?></td></tr>
                        </table>
                    </div>
                    <div class="control">
                        <a href="index.php">List favorite</a><br />
                        <a href="index.php?c=profile">Update profile</a><br />
                        <a href="index.php?c=profile&m=addavatar">Update avatar</a>
                    </div>
                    <div></div>
                </div>
                <div class="main-content">
                    <div class="profile">
                        <h2><span class="header-page">Update profile</span></h2>
                        <br />
					<form action='index.php?c=profile' method='post' id='profile_form' name='profile_form'>
						<table>
							<tr>
								<td colspan='2'><span class='error'><?php echo!empty($this->error) ? $this->error : ''; ?>
								</span></td>
							</tr>
							<tr>
								<td><label for='username'>Username:</label>
								</td>
								<td><span style='font-weight: bold;'><?php echo !empty($this->profile) ? $this->profile->username : ''; ?>
								</span>
								</td>
							</tr>
							<tr>
								<td><label for='name'>Fullname:</label>
								</td>
								<td><input type='input' name='user[name]' id='name'
									value='<?php
											if(!empty($this->userUpdate)){
												echo !empty($this->userUpdate) ? $this->userUpdate->name : '';
											}
											else{
												echo !empty($this->profile) ? $this->profile->name : '';
											}
										?>'
									class="required" minlength="4" size='28' />
								</td>
							</tr>
							<tr>
								<td><label for='password'>Password:</label>
								</td>
								<td><input type='password' name='user[password]' id='password'
									value='' class="required" minlength="4" size='28' /></td>
							</tr>
							<tr>
								<td><label for='repassword'>Re-password:</label>
								</td>
								<td><input type='password' name='user[repassword]'
									id='repassword' value='' class="required" minlength="4"
									size='28' /></td>
							</tr>
							<tr>
								<td><label for='email'>Email:</label>
								</td>
								<td><input type='text' name='user[email]' id='email'
									value='<?php
											if(!empty($this->userUpdate)){
												echo !empty($this->userUpdate) ? $this->userUpdate->email : '';
											}
											else{
											 	echo !empty($this->profile) ? $this->profile->email : '';
											}
										 ?>'
									class="required" minlength="4" size='28' /></td>
							</tr>
							<tr>
								<td><label for='email'>Address:</label>
								</td>
								<td><textarea name='user[address]' id='address' cols='24'><?php
									if(!empty($this->userUpdate)){
										echo !empty($this->userUpdate) ? $this->userUpdate->address : '';
									}
									else{
										echo !empty($this->profile) ? $this->profile->address : '';
									}
								?></textarea>
								</td>
							</tr>
							<tr>
								<td><label for='birthday'>Birthday:</label>
								</td>
								<td>
									<?php list($day, $month, $year) = explode('-', date('d-m-Y', $this->profile->birthday));?>
									<?php //var_dump(date('d-m-Y', $this->userUpdate->birthday)); ?>
								<select id='month' name='user[month]'>
										<?php foreach ($this->month as $key=>$val): ?>
										<option
										<?php
										if(!empty($this->userUpdate)){
											echo $key == $this->userUpdate->month ? "selected='selected'" : '';
										}
										else{
											if(!empty($this->profile)){
												echo $key == $month ? "selected='selected'" : '';
											}
										}
										?>
											value='<?php echo $key; ?>'>
											<?php echo $val; ?>
										</option>
										<?php endforeach; ?>
								</select> <select id='day' name='user[day]'>
										<?php foreach ($this->day as $key=>$val): ?>
										<option
										<?php
										if(!empty($this->profile)){
											echo $key == $day ? "selected='selected'" : '';
										}
										?>
											value='<?php echo $key; ?>'>
											<?php echo $val; ?>
										</option>
										<?php endforeach; ?>
								</select> <select id='year' name='user[year]'>
										<?php foreach ($this->year as $key=>$val): ?>
										<option
										<?php
										if(!empty($this->profile)){
											echo $key == $year ? "selected='selected'" : '';
										}
										?>
											value='<?php echo $key; ?>'>
											<?php echo $val; ?>
										</option>
										<?php endforeach; ?>
								</select>
								</td>
							</tr>
							<tr>
								<td><label for='Sex'>Sex:</label>
								</td>
								<td><input type='radio' name='user[sex]' id='sex_male' value='1'
								<?php
								if(!empty($this->userUpdate)){
									echo !empty($this->userUpdate) ? ($this->userUpdate->sex == 1 ? 'checked="checked"' : '') : 'checked="checked"';
								}
								else {
									echo !empty($this->profile) ? ($this->profile->sex == 1 ? 'checked="checked"' : '') : 'checked="checked"';
								}
								?> />Male
									<input type='radio' name='user[sex]' id='sex_female' value='2'
									<?php
									if(!empty($this->userUpdate)){
										echo !empty($this->userUpdate) ? ($this->userUpdate->sex == 2 ? 'checked="checked"' : '') : '';
									}
									else{
										echo !empty($this->profile) ? ($this->profile->sex == 2 ? 'checked="checked"' : '') : '';
									}
									?> />Female
								</td>
							</tr>
							<tr>
								<td><input type='submit' name='user[register]' id='register'
									value='Register' /></td>
								<td><input type='reset' name='user[reset]' id='reset'
									value='Reset' />&nbsp;&nbsp;&nbsp;<a href="index.php?c=login">Back</a>
								</td>
							</tr>
						</table>
					</form>
				</div>

                </div>
                <div class="right">
                </div>
            </div>
            <div class="clear-fix"></div>
            <div class="footer text-center">
                <a href="#">About</a><span class="separator">|</span>
                <a href="#">Privacy</a><span class="separator">|</span>
                <a href="#">Terms</a><span class="separator">|</span>
                <a href="#">Feedback</a><span class="separator">|</span>
                <a href="#">Copyright</a>
                <br />
            </div>
        </div>
    </body>
</html>